package cn.learn.validate.image;

import cn.learn.validate.ValidateCode;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Getter;
import lombok.Setter;

import java.awt.image.BufferedImage;
import java.time.LocalDateTime;


/**
 * 图形化验证码属性
 *
 * @author huangyezhan
 * @date 2020年02月20日19:28
 */
@Setter
@Getter
public class ImageCode extends ValidateCode {
    private static final long serialVersionUID = 2L;

    /**
     * 验证码图片
     */
    @JSONField(serialize = false)
    private BufferedImage image;

    public ImageCode() {
    }

    /**
     * @param image            验证码生成的验证图片
     * @param code             验证码
     * @param expireTime       有效时长（秒）
     * @param totalValidations 验证的总次数
     */
    public ImageCode(BufferedImage image, String code, int expireTime, int totalValidations) {
        super(code, expireTime, totalValidations);
        this.image = image;
    }

    /**
     * @param image            验证码生成的验证图片
     * @param code             验证码
     * @param expireTime       过期时间
     * @param totalValidations 验证的总次数
     */
    public ImageCode(BufferedImage image, String code, LocalDateTime expireTime, int totalValidations) {
        super(code, expireTime, totalValidations);
        this.image = image;
    }


}
